import Vue from 'vue'
import VueI18n from 'vue-i18n'
import cnlang from '../lang/cn.js'
import enlang from '../lang/en.js'
import chtlang from '../lang/cht.js'


Vue.use(VueI18n)
const lang = localStorage.getItem('lang')?.substring(0, 2) || (navigator.browserLanguage || navigator.language ||
	navigator.userLanguage).substring(0, 2)
// console.log('lang', lang);
export const i18n = new VueI18n({
	locale: lang, // 默认语言
	// locale: 'en', // 默认语言
	messages: {
		'zh': cnlang,
		'en': enlang,
		'cht': chtlang, //繁体
	}
})

export default i18n